package no.ntnu.item.ttm4115.termproject.callhelprole_groupagent;

import java.util.Iterator;

import no.ntnu.item.ttm4115.termproject.AskForHelp;
import no.ntnu.item.ttm4115.termproject.HelpReq;
import no.ntnu.item.ttm4115.termproject.HelpReqFromGA;
import no.ntnu.item.ttm4115.termproject.CHAcceptReq;
import no.ntnu.item.ttm4115.termproject.SessionSetupInfo;
import no.ntnu.item.ttm4115.termproject.AvailableUser;
import no.ntnu.item.ttm4115.termproject.WithdrawHelpReq;
import no.ntnu.item.ttm4115.termproject.callhelpregistryrole_groupagent.CallhelpregistryRole_GroupAgentSM;
import no.ntnu.item.ttm4115.termproject.callhelpregistryrole_groupagent.CallhelpregistryRole_GroupAgentActions;
import no.ntnu.item.ttm4115.termproject.extrasagent.Player;
import no.tellu.common.javaframe.ActorAddress;


public class CallhelpRole_GroupAgentActions extends Object {
	
	public static void handleHelpReq(HelpReq signal, CallhelpRole_GroupAgentSM asm){
		System.out.println("** Vi har mottatt help req! **");
		System.out.println(signal.helpDesc);
		asm.helpDesc = signal.helpDesc;
		System.out.println(asm.helpDesc);
		asm.startTimer(3000, "sendReqToPlayer");
		asm.readyAndAvailableUser = CallhelpregistryRole_GroupAgentActions.getPlayerToSendRequest();
		asm.readyToSendUser = true;
	}

	public static void handleDecline(CallhelpRole_GroupAgentSM asm){
		asm.startTimer(3000, "sendReqToPlayer");
		asm.readyAndAvailableUser = CallhelpregistryRole_GroupAgentActions.getPlayerToSendRequest();
		asm.readyToSendUser = true;
	}

	public static void sendHelpReq(CallhelpRole_GroupAgentSM asm){
	    // TODO edit action statements
		System.out.println(asm.helpDesc);
		HelpReqFromGA req = new HelpReqFromGA("", asm.readyAndAvailableUser);
		req.helpDescription = asm.helpDesc;
		asm.sendMessage(req, asm.readyAndAvailableUser.getActorAddress());
	}

	public static void setupSession(CHAcceptReq signal, CallhelpRole_GroupAgentSM asm){
		asm.sendMessage(new SessionSetupInfo(), signal.getSenderRole());
	}

		public static void withdrawHelpReq(CallhelpRole_GroupAgentSM asm){
			asm.sendMessage(new WithdrawHelpReq(), " address ");
	}






}
